package com.jiangyao.common.configs;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;

import java.util.Date;

/**
 * 数据自动填充处理类
 *
 * @author: yangyongchuan
 * @create: 2020年04月22日 14:57
 */
public class MyMetaObjectHandler implements MetaObjectHandler {
	@Override
	public void insertFill(MetaObject metaObject) {
		Date now = new Date();
		this.setFieldValByName("createdAt", now, metaObject);
//		this.setFieldValByName("createdBy", userId, metaObject);
		this.setFieldValByName("updatedAt", now, metaObject);
//		this.setFieldValByName("updatedBy", userId, metaObject);
	}

	@Override
	public void updateFill(MetaObject metaObject) {
		Date now = new Date();
		this.setFieldValByName("updatedAt", now, metaObject);
//		this.setFieldValByName("updatedBy", userId, metaObject);
	}
}
